﻿@namespace MudBlazor
@inherits ComponentBase
@typeparam T
@using Microsoft.AspNetCore.Components.Web.Virtualization 

@if (Enabled)
{
    if (ItemsProvider is not null)
    {
        <Virtualize TItem="T" @ref="@_virtualizeContainerReference" ItemsProvider="@ItemsProvider" Context="item" OverscanCount="@OverscanCount" ItemSize="@ItemSize" SpacerElement="@SpacerElement">
            <ChildContent>
                @if (ChildContent is not null)
                {
                    @ChildContent(item)
                }
            </ChildContent>
            <Placeholder>
                @Placeholder
            </Placeholder>
            <EmptyContent>
                @NoRecordsContent
            </EmptyContent>
        </Virtualize>
    }
    else
    {
        <Virtualize TItem="T" @ref="@_virtualizeContainerReference" Items="@Items" Context="item" OverscanCount="@OverscanCount" ItemSize="@ItemSize" SpacerElement="@SpacerElement">
            <ChildContent>
                @if (ChildContent is not null)
                {
                    @ChildContent(item)
                }
            </ChildContent>
            <Placeholder>
                @Placeholder
            </Placeholder>
            <EmptyContent>
                @NoRecordsContent
            </EmptyContent>
        </Virtualize>
    }
}
else if (Items?.Any() != true)
{
    @NoRecordsContent
}
else
{
    @foreach (var item in Items)
    {
        if (ChildContent is not null)
        {
            @ChildContent(item)
        }
    }
}